<template>
  <el-card shadow="never" class="list-card">
    <div slot="header" style="text-align: center">
      <span>考评方案基本信息</span>
    </div>
    <el-form label-width="100px">
      <el-form-item label="任务类型">
        <span>{{ item.internalPlanType && computeTitle(item.internalPlanType) }}</span>
      </el-form-item>
      <el-form-item label="考评任务周期">
        <span>{{ judgeRange(item.internalPlanCycle) }}</span>
      </el-form-item>
      <el-form-item label="任务日期">
        <span>{{ item.startDate ? formatTime(item.startDate, 'day') : null }}{{ item.endDate ? `至${formatTime(item.endDate, 'day')}` : null }}</span>
      </el-form-item>
      <el-form-item label="创建人">{{ item.createUser }}</el-form-item>
      <el-form-item label="创建时间">{{ item.createTime ? formatTime(item.createTime) : null }}</el-form-item>
      <el-form-item label="任务状态">
        <span>
          <el-tag :type="judgeType(item.state)">{{ judgeState(item.state) }}</el-tag>
        </span>
      </el-form-item>
    </el-form>
  </el-card>
</template>

<script>
import { judgeRange, judgeEvalState, judgeType } from '@/utils/util'

export default {
  data() {
    return {
      item: {}
    }
  },
  methods: {
    computeTitle(num) {
      let str = ''
      switch (num) {
        case 1:
          str = '科间互评'
          break
        case 2:
          str = '科内互评'
          break
        case 3:
          str = '评上级领导'
          break
        case 4:
          str = '自定义'
          break
        default:
          break
      }
      return str
    },
    show(row) {
      this.item = Object.assign({}, row)
    },
    judgeType(num) {
      return judgeType(num)
    },
    judgeState(num) {
      return judgeEvalState(num)
    },
    judgeRange(num) {
      return judgeRange(num)
    }
  }
}
</script>

<style scoped>
.list-card .el-form .el-form-item {
  margin-bottom: 10px;
}
</style>